package com.example.livemall.mapper;

import com.example.livemall.entity.Comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 商品评论服务数据层
 */
@Mapper
public interface CommentMapper {

    /**
     * 查询评论评论
     *
     * @param query
     * @return
     */
    @Select("select * from comment " +
            "where item_id = #{itemId} " +
            "limit #{offset}, #{size} ")
    List<Comment> selectCommentList(String itemId, int offset, int size);

    /**
     * 根据商品主键查询评论数量
     *
     * @param itemId
     * @return
     */
    @Select("select count(*) from comment where item_id = #{itemId}")
    long countByQuery(String itemId);

}